package com.usian.controller;

import com.usian.feign.ContentServiceFeign;
import com.usian.utils.PageResult;
import com.usian.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author lpf
 * @Date 2022/3/24 下午3:09
 * @ProjectName java134-e-commerce-project
 * @Version 1.0
 * @Description:
 */
@RestController
@RequestMapping(value = "backend/content")
public class ContentController {
    @Autowired
    private ContentServiceFeign contentServiceFeign;

    /**
     * 根据categoryID查询内容接口
     * @param rows
     * @param pages
     * @param categoryId
     * @return
     * @Auth lpf
     */
    @RequestMapping(value = "selectTbContentAllByCategoryId")
    public Result selectTbContentAllByCategoryId(@RequestParam(defaultValue = "2") Integer rows,
                                                 @RequestParam(defaultValue = "1") Integer pages,
                                                 Long categoryId){
        PageResult pageResult = contentServiceFeign.selectTbContentAllByCategoryId(rows, pages, categoryId);
        if (pageResult.getResult() != null && pageResult.getResult().size() > 0){
            return Result.ok(pageResult);
        }
        return Result.error("查询失败！");
    }
}
